package logic

import (
	"context"
	"user/common"
	"user/models"

	"user/internal/svc"
	"user/pb/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type DeleteUserLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDeleteUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteUserLogic {
	return &DeleteUserLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// DeleteUser 删除用户
func (l *DeleteUserLogic) DeleteUser(in *user.UserInfo) (*user.Empty, error) {
	err := l.svcCtx.UserModel.Update(l.ctx, &models.User{Id: in.Id, Status: common.UserStatusDisabled})
	if err != nil {
		return nil, err
	}
	return &user.Empty{}, nil
}
